package org.jeecg.weixin.web.utils;

import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;

/**
 * @author Binary Wang(https://github.com/binarywang)
 */
public class JsonUtils {
	private static final ObjectMapper JSON = new ObjectMapper();

	static {
		JSON.setSerializationInclusion(Include.NON_NULL);
		JSON.configure(SerializationFeature.INDENT_OUTPUT, Boolean.TRUE);
	}

	public static String toJson(Object obj) {
		try {
			return JSON.writeValueAsString(obj);
		} catch (JsonProcessingException e) {
			e.printStackTrace();
		}

		return null;
	}
}
